package cn.tedu.store.service;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import cn.tedu.store.entity.Address;
import cn.tedu.store.service.exception.ServiceException;

@RunWith(SpringRunner.class)
@SpringBootTest
public class AddressServiceTestCase {
	
	@Autowired
	private IAddressService addressService;

	@Test
	public void create(){
		Address address = new Address();
		String username = "王俊";
		address.setUid(3);
		address.setName("小刘同学");
		address.setProvince("440000");
		address.setCity("440300");
		address.setArea("440305");
		Address result = addressService.create(username, address);
		System.err.println("result="+result);
	}
	
	@Test
	public void getListByUid(){
		Integer uid = 4;
		List<Address>list = addressService.getListByUid(uid);
		for(Address address : list){
			System.err.println("address="+address);
		}
	}
	
	@Test
	public void setDefault(){
		try {
			Integer uid = 4;
			Integer id = 5;
			addressService.setDefault(uid, id);
			System.err.println("OK.");
		} catch (ServiceException e) {
			System.err.println("错误类型：" + e.getClass().getName());
			System.err.println("错误描述：" + e.getMessage());
		}
	}

	@Test
	public void delete() {
		try {
			Integer uid = 4;
			Integer id = 6;
			addressService.delete(uid,id);
			System.err.println("OK.");
		} catch (ServiceException e) {
			System.err.println("错误类型：" + e.getClass().getName());
			System.err.println("错误描述：" + e.getMessage());
		}
	}
	
	
	
	
	
}
